package org.wingstudio.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.wingstudio.entity.Leader;
import org.wingstudio.entity.Part;
import org.wingstudio.service.LeaderService;
import org.wingstudio.service.PartService;
import javax.annotation.Resource;
import java.util.List;

/**
 * Created by liao on 16-12-4.
 */

@Controller
@RequestMapping("/part")
public class PartNormalController {
    @Resource
    private LeaderService leaderService;
    @Resource
    private PartService partService;

    @RequestMapping("/leader")
    public ModelAndView leader(){
        ModelAndView modelAndView=new ModelAndView();

        List<Leader> leaderList=leaderService.list();
        Leader leader1=leaderList.get(0);
        leaderList.remove(0);
        modelAndView.addObject("leader1",leader1);
        modelAndView.addObject("leaderList",leaderList);
        modelAndView.setViewName("user/part/leader");
        return modelAndView;
    }

    @RequestMapping("/introduce")
    public ModelAndView introduce(){
        ModelAndView modelAndView=new ModelAndView();

        Part part=partService.getPart(5);
        modelAndView.addObject("part",part);
        modelAndView.setViewName("user/part/introduce");
        return modelAndView;
    }

    @RequestMapping("/office")
    public ModelAndView office(){
        ModelAndView modelAndView=new ModelAndView();
        Part part=partService.getPart(1);
        modelAndView.addObject("part",part);
        modelAndView.setViewName("user/part/office");
        return modelAndView;
    }

    @RequestMapping("/base")
    public ModelAndView base(){
        ModelAndView modelAndView=new ModelAndView();
        Part part=partService.getPart(2);
        modelAndView.addObject("part",part);
        modelAndView.setViewName("user/part/base");
        return modelAndView;
    }

    @RequestMapping("/equipment")
    public ModelAndView equipment(){
        ModelAndView modelAndView=new ModelAndView();
        Part part=partService.getPart(3);
        modelAndView.addObject("part",part);
        modelAndView.setViewName("user/part/equipment");
        return modelAndView;
    }

    @RequestMapping("/land")
    public ModelAndView land(){
        ModelAndView modelAndView=new ModelAndView();
        Part part=partService.getPart(4);
        modelAndView.addObject("part",part);
        modelAndView.setViewName("user/part/land");
        return modelAndView;
    }
}
